package starter;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;

import status.ClientStatusEnum;

import controller.Admin;

import businnes.Client;
import businnes.Job;

import dao.ClientDAO;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:testApplicationContext.xml" })
//@Transactional
public class ClientDAOJPA2Test {

	@Autowired
	private ClientDAO clientDAO;
	
	@Test
	public void shallWork(){
		Client client = new Client();
		client.setDescription("Pepeluis");
		List<Job> jobs = new ArrayList<Job>();
		client.setJobs(jobs);
		client.setStatus(ClientStatusEnum.ACTIVE);
		Admin admin = new Admin();
		admin.setClientDAO(clientDAO);
		Long id = admin.addClient(client);
		System.out.println("The id created is: "+id);
		List<Client> clients = admin.getAll();
		for (Client client2 : clients) {
			System.out.println(client2.getDescription());
		}
	}

	public void setClientDAO(ClientDAO clientDAO) {
		this.clientDAO = clientDAO;
	}
	
	
}
